{% extends "tasks/base.html" %}

{% load i18n %}
{% load account_tags %}
{% load tasks_tags %}
{% load shorttimesince_tag %}
{% load humanize %}
{% load group_tags %}

{% block head_title %}Planning {% user_display other_user %}'s next day{% endblock %}

{% block body %}
  <table class="dayplan">
    <tr>
      <th>Planned tasks for the day</th>
      <th>Pool of tasks not yet scheduled</th>
    </tr>
    <tr>
      <td> 
        {% if planned_task_exists %}
        
          <table class="task_list">
            {% cycle odd even as rowcolors %}
            <tr>
                <th>Summary (click to remove task)</th>
                <th></th>
            </tr>

            {% if first_tasks %}
              {% with "first" as section %}
              {% with first_tasks as tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            {{ section }}
                        </span>
                    </td>
                </tr></tbody>
                    <tbody class="task_group" id="group_{{ section }}">
                      {% for task in tasks %}
                        <tr class="task_{{ task.get_recur_display }}{{ task.is_planned }} 
                          {% if task.last_worked_date %}worked_on{% endif %} 
                          {% cycle rowcolors %}">
                                  <td><a href="{% groupurl unplan group username=other_user id=task.id %}">{{ task.summary }}</a></td>
                                  <td><a href="{% groupurl task_detail group id=task.id %}">Edit</a></td>
                        </tr>
                      {% endfor %}
                    </tbody>
              {% endwith %}
              {% endwith %}
            {% else %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            No first task specified.
                        </span>
                    </td>
                </tr></tbody>
            {% endif %}

            {% if before_tasks %}
              {% with "before" as section %}
              {% with before_tasks as tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            {{ section }}
                        </span>
                    </td>
                </tr></tbody>
                    <tbody class="task_group" id="group_{{ section }}">
                      {% for task in tasks %}
                        <tr class="task_{{ task.get_recur_display }}{{ task.is_planned }} 
                          {% if task.last_worked_date %}worked_on{% endif %} 
                          {% cycle rowcolors %}">
                                  <td><a href="{% groupurl unplan group username=other_user id=task.id %}">{{ task.summary }}</a></td>
                                  <td><a href="{% groupurl task_detail group id=task.id %}">Edit</a></td>
                        </tr>
                      {% endfor %}
                    </tbody>
              {% endwith %}
              {% endwith %}
            {% else %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            No before task specified.
                        </span>
                    </td>
                </tr></tbody>
            {% endif %}
            
            {% if normal_tasks %}
              {% with "normal" as section %}
              {% with normal_tasks as tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            {{ section }}
                        </span>
                    </td>
                </tr></tbody>
                    <tbody class="task_group" id="group_{{ section }}">
                      {% for task in tasks %}
                        <tr class="task_{{ task.get_recur_display }}{{ task.is_planned }} 
                          {% if task.last_worked_date %}worked_on{% endif %} 
                          {% cycle rowcolors %}">
                                  <td><a href="{% groupurl unplan group username=other_user id=task.id %}">{{ task.summary }}</a></td>
                                  <td><a href="{% groupurl task_detail group id=task.id %}">Edit</a></td>
                        </tr>
                      {% endfor %}
                    </tbody>
              {% endwith %}
              {% endwith %}
            {% else %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            No normal task specified.
                        </span>
                    </td>
                </tr></tbody>
            {% endif %}
            
            {% if after_tasks %}
              {% with "after" as section %}
              {% with after_tasks as tasks %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            {{ section }}
                        </span>
                    </td>
                </tr></tbody>
                    <tbody class="task_group" id="group_{{ section }}">
                      {% for task in tasks %}
                        <tr class="task_{{ task.get_recur_display }}{{ task.is_planned }} 
                          {% if task.last_worked_date %}worked_on{% endif %} 
                          {% cycle rowcolors %}">
                                  <td><a href="{% groupurl unplan group username=other_user id=task.id %}">{{ task.summary }}</a></td>
                                  <td><a href="{% groupurl task_detail group id=task.id %}">Edit</a></td>
                        </tr>
                      {% endfor %}
                    </tbody>
              {% endwith %}
              {% endwith %}
            {% else %}
                <tbody><tr class="task_grouping">
                    <td colspan="5">
                        <span class="toggle">
                            No after task specified.
                        </span>
                    </td>
                </tr></tbody>
            {% endif %}
            
        </table>
        
        {% else %}
          {% trans "You have no planned tasks for tha date right now." %}
        {% endif %}
      </td>
      <td>
        {% if pool_tasks %}
          <br></br>    
          <br></br>    
          <table class="task_list">
            {% cycle odd even as rowcolors %}
            <tr>
              <th>Summary (click to add task)</th>
              <th></th>
            </tr>

            {% with "pool" as section %}
              {% with pool_tasks as tasks %}
                  <tbody class="task_group" id="group_{{ section }}">
                    {% for task in tasks %}
                      <tr class="task_{{ task.get_recur_display }} 
                        {% if task.last_worked_date %}worked_on{% endif %} 
                        {% cycle rowcolors %}">
                                <td><a href="{% groupurl plan group username=other_user id=task.id %}">{{ task.summary }}</a></td>
                                <td><a href="{% groupurl task_detail group id=task.id %}">Edit</a></td>
                      </tr>
                    {% endfor %}
                  </tbody>
              {% endwith %}
            {% endwith %}
          </table>
          
        {% else %}
          {% trans "You have no pool tasks right now." %}
        {% endif %}
      </td>
    </tr>
  </table>
    
{% endblock %}
